
import 'package:flutter/material.dart';
import 'package:location/location.dart';
import 'package:shared_preferences/shared_preferences.dart';



// 记录全局信息，
class Application{
  static GlobalKey<NavigatorState> key = GlobalKey();
  static SharedPreferences sp;
  static double screenWidth;
  static double screenHeight;
  static double statusBarHeight;
  static double bottomBarHeight;
  static LocationData currentLocation;
  // 用于service管理
  static bool ISDEBUG = true;
  static String token = "";


  static initSp() async{
    // 持久化存储单例
    sp = await SharedPreferences.getInstance();
  }

  static initLocation() async {

    var location = new Location();

    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      currentLocation = await location.getLocation();
    } on Exception catch (e) {
      debugPrint(e.toString());
      // if (e.code == 'PERMISSION_DENIED') {
      //   error = 'Permission denied';
      // } 
      currentLocation = null;
    }
  }
}